package com.ny609;

import java.sql.*;
import java.util.Scanner;

public class Login {
    private final static String URL = "jdba:mysql://localhost:3306/pdd";
    private final static String ROOT = "root";
    private final static String PASSWORD = "123456";

    public static void main(String[] args) throws SQLException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名");
        String name = scanner.next();
        System.out.println("请输入密码");
        String pwd = scanner.next();
        Connection connection = DriverManager.getConnection(URL,ROOT,PASSWORD);
        String sql = "select * from uers where username =? and password =?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);;
        preparedStatement.setString(1,name);
        preparedStatement.setString(2,pwd);
        ResultSet resultSet = preparedStatement.executeQuery();
        if (resultSet.next()){
            System.out.println("登录成功");
        }
        else{
            System.out.println("登录失败");
        }

    }
}
